﻿Imports Autodesk.AutoCAD.Runtime
Imports System
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
Imports Licenta3.SetariClassViewModel
Imports Licenta3.GlobalVars
Imports Licenta3.Common.Classes
Imports System.Data


Public Class initialization
    Implements IExtensionApplication

    Public Sub Initialize() Implements IExtensionApplication.Initialize
        Try
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\System.Windows.Interactivity.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Xceed.Wpf.Toolkit.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Controls.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Controls.GridView.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Controls.Input.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Data.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Controls.Data.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Controls.Docking.dll")
            System.Reflection.Assembly.LoadFrom(assemblyPath & "\Telerik.Windows.Controls.Charting.dll")
            'Dim Setari As New SetariClass
            If File.Exists(setariPath) Then
                Dim setarile As New SetariClass
                setarile.ReadFromXML(setariPath)
            End If
            If Not Directory.Exists(SetariClass._LucruPath) Then
                SetariClass._LucruPath = assemblyPath
            End If
        Catch ex As System.Exception
            MsgBox(ex.Message + ex.StackTrace + ex.Source)
        End Try
    End Sub

    Public Sub Terminate() Implements IExtensionApplication.Terminate
        ''Serialize object to a text file.
        Try
            '    Dim xSetarile As New XmlSerializer(GetType(SetariClass))
            Dim setaripath As String = assemblyPath + "\setari.xml"
            Dim _setarile As New SetariClass
            _setarile.SaveToXML(setaripath)
            '    Dim objStreamWriter As New StreamWriter(setaripath)
            '    xSetarile.Serialize(objStreamWriter, _setarile)
            '    objStreamWriter.Close()
        Catch ex As System.Exception
            MsgBox(ex.Message + ex.StackTrace + ex.Source)
        End Try
    End Sub

End Class
